<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@include file="/common/mytags.jsp" %>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>角色列表</title>
    <!-- load css -->
    <link rel="stylesheet" type="text/css" href="<%=basePath%>common/frame/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>common/css/gobal.css" media="all">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>backstage/css/common.css" media="all">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>backstage/css/flink.css" media="all">
    <style type="text/css">
        .layui-icon{
            margin-top: 12px;
        }
    .layui-table-view{
    width:99.5% !important;
    }
    </style>
</head>
</head>
<body>
<div class="layui-fluid larry-wrapper">

    <blockquote class="layui-elem-quote larry-btn" style="height: 35px;">
        <form class="layui-form" action="" method="post" >
            <div class="layui-input-inline ">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-block">
                    <input style="width: 180px;" type="text" name="name"  id="name" class="layui-input" placeholder="请输入角色名称" >
                </div>
            </div>
            <a class="layui-btn" data-type="getSelect" id="getSelect" >查询</a>
        </form>
    </blockquote>

    <div class="flinkTable">
        <table class="layui-table"   style=" "  id="bannerPage" lay-filter="bannerPage"></table>
    </div>


</div>
<script type="text/html" id="merchantBar">
    <authority:auto target="USER_ROLE_INNER" >
        <a class="layui-btn layui-btn-xs " lay-event="select">选择</a>&nbsp;
    </authority:auto>

</script>

<script type="text/javascript" src="<%=basePath%>common/frame/layui/layui.js"></script>

<script>
    layui.config({
        base: "<%=basePath%>common/larrylib/",
        version: '201708031'
    }).use(["layer", "form", "table", "jquery", "laydate", "upload"], function () {
        var $ = layui.jquery;
        var e = layui.$, t = layui.layer, i = layui.form, l = layui.table;
        var width = $(document).width();
        var height = $(document).height();

      var a = l.render({
            elem: "#bannerPage",
            width: width,
            height: 'full-140',
            id: 'table',
            size: 'lg',
            cols: [[
                {checkbox:true, type:'checkbox',fixed: 'left',width: width * 0.1},
                {field: 'name', title: '角色名称', align: "center", width: width * 0.5},
                {title: "常用操作", width: width * 0.3, align: "center", toolbar: "#merchantBar", fixed: "right"}
            ]],
            request: {
            pageName: 'pageNumber',
            limitName: 'pageSize'
            },
            response: {
            statusName: 'state' //数据状态的字段名称，默认：code
            , statusCode: 200 //成功的状态码，默认：0
            , msgName: 'message' //状态信息的字段名称，默认：msg
            , countName: 'totalRow' //数据总数的字段名称，默认：count
            , dataName: 'data' //数据列表的字段名称，默认：data
            },
            url: "<%=basePath%>auth/role/list",
            page: true,
            limit: 10,
            even: true
        });
	   

      
        l.on("tool(bannerPage)", function (e) {
            var i = e.data;
            var name = i.name;
            if (e.event == "select") {
                t.confirm("确定分配"+name+"角色，确认吗？", {
                    icon: 3,
                    skin: 'larry-green',
                    title: "系统提示",
                    offset: '200px',
                    closeBtn: 0,
                    skin: 'layui-layer-molv',
                    anim: Math.ceil(Math.random() * 6),
                    btn: ['确定', '取消']
                }, function (index) {
                    $.ajax({
                        url: '<%=basePath%>user/role/innerRole',
                        type: 'post',
                        async: false,
                        data: {roleId:i.id,userId:'${requestScope.userId}'},
                        dataType: "json",
                        success: function (data) {
                            if (data.state == 200) {
                                t.msg(data.message, {icon: 6});
                                closeIframe(true);
                                return true;
                            } else {
                                t.msg(data.message, {icon: 5});
                                return false;
                            }
                        }, error: function () {
                            top.layer.msg("系统数据处理异常！", {icon: 2});
                            return false;
                        }
                    });
                    layer.close(index);
                }, function (index) {

                    layer.close(index);
                });
            }

        });


        e(".larry-btn a.layui-btn").on("click", function () {
            var t = e(this).data("type");
            r[t] ? r[t].call(this) : "";
        });

        var r = {
            getSelect: function () {
                var i = t.msg("查询中，请稍候...", {icon: 16, time: false, shade: 0});
                var name = e("#name").val();
                l.reload('table', {
                    where: {
                        name:name
                    },method:'post',
                    height: 'full-140'
                });
                t.close(i);
            }

        };
       

    });

</script>


</body>
</html>